package com.ambulance.project.biz.controller.manager;

import com.ambulance.common.utils.poi.ExcelUtil;
import com.ambulance.framework.aspectj.lang.annotation.Log;
import com.ambulance.framework.aspectj.lang.enums.BusinessType;
import com.ambulance.framework.web.controller.BaseController;
import com.ambulance.framework.web.domain.AjaxResult;
import com.ambulance.framework.web.page.TableDataInfo;
import com.ambulance.project.manager.domain.BizDispatchcase;
import com.ambulance.project.manager.service.IBizDispatchcaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 调度病例详细信息Controller
 *
 * @author zr
 * @date 2020-05-11
 */
@RestController
@RequestMapping("/manager/dispatchCase")
public class BizDispatchCaseController extends BaseController {
    @Autowired
    private IBizDispatchcaseService bizDispatchcaseService;

    /**
     * 查询调度病例详细信息列表
     */
    //@PreAuthorize("@ss.hasPermi('manager:dispatchCase:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizDispatchcase bizDispatchcase) {
        startPage();
        List<BizDispatchcase> list = bizDispatchcaseService.selectBizDispatchcaseList(bizDispatchcase);
        return getDataTable(list);
    }

    /**
     * 导出调度病例详细信息列表
     */
    //@PreAuthorize("@ss.hasPermi('manager:dispatchCase:export')")
    @Log(title = "调度病例详细信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BizDispatchcase bizDispatchcase) {
        List<BizDispatchcase> list = bizDispatchcaseService.selectBizDispatchcaseList(bizDispatchcase);
        ExcelUtil<BizDispatchcase> util = new ExcelUtil<BizDispatchcase>(BizDispatchcase.class);
        return util.exportExcel(list, "dispatchCase");
    }

    /**
     * 获取调度病例详细信息详细信息
     */
    //@PreAuthorize("@ss.hasPermi('manager:dispatchCase:query')")
    @GetMapping(value = "/{dispatchCaseID}")
    public AjaxResult getInfo(@PathVariable("dispatchCaseID") Long dispatchCaseID) {
        return AjaxResult.success(bizDispatchcaseService.selectBizDispatchcaseById(dispatchCaseID));
    }

    /**
     * 新增调度病例详细信息
     */
    //@PreAuthorize("@ss.hasPermi('manager:dispatchCase:add')")
    @Log(title = "调度病例详细信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizDispatchcase bizDispatchcase) {
        return toAjax(bizDispatchcaseService.insertBizDispatchcase(bizDispatchcase));
    }

    /**
     * 修改调度病例详细信息
     */
    //@PreAuthorize("@ss.hasPermi('manager:dispatchCase:edit')")
    @Log(title = "调度病例详细信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizDispatchcase bizDispatchcase) {
        return toAjax(bizDispatchcaseService.updateBizDispatchcase(bizDispatchcase));
    }

    /**
     * 删除调度病例详细信息
     */
    //@PreAuthorize("@ss.hasPermi('manager:dispatchCase:remove')")
    @Log(title = "调度病例详细信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{dispatchCaseIDs}")
    public AjaxResult remove(@PathVariable Long[] dispatchCaseIDs) {
        return toAjax(bizDispatchcaseService.deleteBizDispatchcaseByIds(dispatchCaseIDs));
    }
}
